#pragma once

#include "StdAfx.h"
#include "Player.h"
#include "Terrain.h"

class Garuda:
	public Ogre::FrameListener,
	public Ogre::WindowEventListener,
	public OIS::KeyListener,
	public OIS::MouseListener,
	public OgreBites::SdkTrayListener
{
/* Fields */
public:
private:
	Ogre::Root *root;
	Ogre::SceneManager *sceneMgr;
	Ogre::RenderWindow *window;
	Ogre::String resourcesCfg;
	Ogre::String pluginsCfg;

	Terrain *terrain;
	std::map<long, Player*> *players;
	Player *player;

/* Methods */
public:
	Garuda();
	~Garuda();
	void go();
private:
	bool setup();
	void setupResources();
	bool configure();
	void chooseSceneManager();
	void createViewports();
	void createResourceListener();
	void loadResources();
	void createScene();
	void createFrameListener();
	void configureTerrainDefaults(Ogre::Light* light);
	void defineTerrain(long x, long y);
	void initBlendMaps(Ogre::Terrain* terrain);
	void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img);
	bool frameRenderingQueued(const Ogre::FrameEvent& evt);
	bool keyPressed(const OIS::KeyEvent &arg);
	bool keyReleased(const OIS::KeyEvent &arg);
	bool mouseMoved(const OIS::MouseEvent &arg);
	bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
	bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
	void windowResized(Ogre::RenderWindow* rw);
	void windowClosed(Ogre::RenderWindow* rw);
	void destroyScene();
};